function calculateCycleDate(e, t, n, a, o, r, s) {
    var i = false;
    var l;
    if (o == "return") {
        l = r;
        i = true
    } else {
        l = r + 180;
        if (l > 360) {
            l -= 360
        }
    }
    if (s == null) {
        var c = e;
        if (n == "chiron") {
            c.day += 7e3
        }
        if (n == "saturn" || n == "uranus") {
            c.day += 2e3
        } else {
            c.day += 10
        }
        s = c
    }
    return calArrivalDate(n, a, l, t, s, i)
}
function getOffset(e, t) {
    var n = 0;
    if (e < t)
        n = 360 - Math.abs(e - t);
    else if (e > t)
        n = Math.abs(e - t);
    return n
}
function calLongFromDate(e, t) {
    $processor.calc(e, t);
    return $const.body.position.apparentLongitude
}
function calLongFromJul(e, t) {
    if (["chiron", "true_node", "mars"].indexOf(t.key) !== -1) {
        const o = t.key === "chiron" ? $moshier.col_param.chiron_ephemeris_interval : t.key === "true_node" ? $moshier.col_param.node_ephemeris_interval : $moshier.col_param.mars_ephemeris_interval;
        const r = t.key === "chiron" ? $moshier.col_param.chiron_ephemeris_min : t.key === "true_node" ? $moshier.col_param.node_ephemeris_min : $moshier.col_param.mars_ephemeris_min;
        const s = t.key === "chiron" ? $moshier.col_param.chiron_ephemeris_start : t.key === "true_node" ? $moshier.col_param.node_ephemeris_start : $moshier.col_param.mars_ephemeris_start;
        const i = 1 / o;
        const l = Math.floor(e * i) / i;
        const c = Math.ceil(e * i) / i;
        const u = r[Math.round((l - s) / o)];
        const h = r[Math.round((c - s) / o)];
        const d = u + (e - l) * i * (h - u);
        return d
    }
    var n = {
        julian: e
    };
    var a = $julian.toGregorian(n);
    return calLongFromDate(a, t)
}
function getSpeedMulti(e) {
    return e > 10 ? .05 : e > 1 ? .025 : 0
}
function getNextTimeDelta(e, t, n, a) {
    var o = 0;
    var r = t / n;
    if (a) {
        o = getSpeedMulti(t);
        if (o == 0)
            a = false
    }
    var s;
    if (a) {
        s = r * o;
        if (s > 365)
            s = 365
    } else {
        if (t > 10)
            s = 10;
        else if (t > 1)
            s = .5;
        else if (t > .1)
            s = .05;
        else if (t > .01)
            s = .005;
        else if (t > .001)
            s = 5e-4;
        else if (t > 1e-4)
            s = 5e-5;
        else if (t > 1e-5)
            s = 5e-6;
        else
            s = 5e-7;
        if (e == "sun")
            s /= 1;
        else if (e == "moon")
            s /= 10;
        else if (e == "saturn")
            s *= 2;
        else if (["uranus", "chiron"].includes(e))
            s *= 10
    }
    return {
        num3: s,
        useAverageSpeed: a
    }
}
function calArrivalDate(e, t, n, a, o, r, s=1e4, i=true) {
    var l = a;
    var c = 1;
    var u = e == "moon" ? .001 : 1e-4;
    var h = i;
    var d = false;
    var f = false;
    var p = true;
    var m = 50;
    var g = $julian.calc(o);
    l += g - a;
    if (e == "moon")
        m = 20;
    var y = calLongFromJul(l, t);
    var v = Math.abs(calLongFromJul(l + m, t) - y) / m;
    if (y > n || r)
        d = true;
    else
        f = true;
    var b = getOffset(n, y);
    p = b > 1e-6;
    if (b < 1)
        h = false;
    while (p) {
        var $ = getNextTimeDelta(e, b, v, h);
        var M = $.num3;
        h = $.useAverageSpeed;
        l += M;
        var C = calLongFromJul(l, t);
        if (e != "moon" && e != "sun")
            v = (v + Math.abs(C - y) / M) / 2;
        if (d) {
            if (C < n) {
                d = false;
                f = true
            }
        } else if (e != "chiron" && C > n && c > 1 && C < 340) {
            l -= M;
            h = false;
            calLongFromJul(l, t)
        }
        y = C;
        b = getOffset(n, y);
        c++;
        if (c > s) {
            l = 2816422.5;
            p = false
        }
        if (b < 1e-6)
            p = false;
        if (f && y > n && Math.abs(y - n) < u)
            p = false
    }
    var $ = {
        julian: l
    };
    var x = $julian.toGregorian($);
    x.seconds += 1;
    var L = new Date(x.year,x.month - 1,x.day,x.hours,x.minutes,x.seconds,0);
    return [L, l]
}
function calculateDesignDate(e, t) {
    var n = t - 88;
    if (n < 0)
        n += 360;
    var a = e - 95;
    var o = 0;
    var r = calLongFromJul(a, $moshier.body.sun);
    var s = n - r;
    if (r < n) {
        while (r < n) {
            if (s > 1)
                a += .1;
            else if (s > .1)
                a += .05;
            else if (s > .01)
                a += .005;
            else if (s > .001)
                a += 5e-4;
            else if (s > 1e-4)
                a += 5e-5;
            else if (s > 1e-5)
                a += 5e-6;
            else
                a += 5e-7;
            r = calLongFromJul(a, $moshier.body.sun);
            s = n - r
        }
    } else {
        s = 360 - r + n;
        while (r > n) {
            if (s > 1)
                a += .1;
            else if (s > .1)
                a += .05;
            else if (s > .01)
                a += .005;
            else if (s > .001)
                a += 5e-4;
            else if (s > 1e-4)
                a += 5e-5;
            else if (s > 1e-5)
                a += 5e-6;
            else
                a += 5e-7;
            r = calLongFromJul(a, $moshier.body.sun);
            s = 360 - r + n
        }
        s = n - r;
        while (r < n) {
            if (s > 1)
                a += .1;
            else if (s > .1)
                a += .05;
            else if (s > .01)
                a += .005;
            else if (s > .001)
                a += 5e-4;
            else if (s > 1e-4)
                a += 5e-5;
            else if (s > 1e-5)
                a += 5e-6;
            else
                a += 5e-7;
            r = calLongFromJul(a, $moshier.body.sun);
            s = n - r
        }
    }
    var i = {
        julian: a
    };
    return $julian.toGregorian(i)
}
function calculateMoonDesignDate(e, t) {
    var n = t - 88;
    if (n < 0)
        n += 360;
    var a = e - 8;
    var o = 0;
    var r = calLongFromJul(a, $moshier.body.moon);
    var s = n - r;
    if (r < n) {
        while (r < n) {
            if (s > 1)
                a += .1;
            else if (s > .1)
                a += .01;
            else if (s > .01)
                a += .001;
            else if (s > .001)
                a += 1e-4;
            else if (s > 1e-4)
                a += 1e-5;
            else if (s > 1e-5)
                a += 1e-6;
            else
                a += 1e-7;
            r = calLongFromJul(a, $moshier.body.moon);
            s = n - r
        }
    } else {
        s = 360 - r + n;
        while (r > n) {
            if (s > 1)
                a += .1;
            else if (s > .1)
                a += .01;
            else if (s > .01)
                a += .001;
            else if (s > .001)
                a += 1e-4;
            else if (s > 1e-4)
                a += 1e-5;
            else if (s > 1e-5)
                a += 1e-6;
            else
                a += 1e-7;
            r = calLongFromJul(a, $moshier.body.moon);
            s = 360 - r + n
        }
        s = n - r;
        while (r < n) {
            if (s > 1)
                a += .1;
            else if (s > .1)
                a += .01;
            else if (s > .01)
                a += .001;
            else if (s > .001)
                a += 1e-4;
            else if (s > 1e-4)
                a += 1e-5;
            else if (s > 1e-5)
                a += 1e-6;
            else
                a += 1e-7;
            r = calLongFromJul(a, $moshier.body.moon);
            s = n - r
        }
    }
    var i = {
        julian: a
    };
    return $julian.toGregorian(i)
}
const hexMap = [17, 21, 51, 42, 3, 27, 24, 2, 23, 8, 20, 16, 35, 45, 12, 15, 52, 39, 53, 62, 56, 31, 33, 7, 4, 29, 59, 40, 64, 47, 6, 46, 18, 48, 57, 32, 50, 28, 44, 1, 43, 14, 34, 9, 5, 26, 11, 10, 58, 38, 54, 61, 60, 41, 19, 13, 49, 30, 55, 37, 63, 22, 36, 25];
const Planets = {
    SUN: "sun",
    EARTH: "earth",
    MOON: "moon",
    TRUE_NODE: "true_node",
    SOUTH_NODE: "south_node",
    MERCURY: "mercury",
    VENUS: "venus",
    MARS: "mars",
    JUPITER: "jupiter",
    SATURN: "saturn",
    URANUS: "uranus",
    NEPTUNE: "neptune",
    PLUTO: "pluto",
    CHIRON: "chiron"
};
function calculatePlanetData(c, u, h) {
    var e = Object.values(Planets);
    e.forEach((e,t)=>{
            if (t != 1 && t != 4) {
                var n = getPlanetBody(e);
                var a = {
                    ID: t,
                    activationType: h,
                    enabled: true,
                    name: e
                };
                if (t == 13)
                    a.enabled = false;
                var o = calLongFromJul(u, n);
                a.longitude = o;
                var r = getPosInHexagram(o);
                var s = Math.trunc(r);
                a.Gate = hexMap[Math.trunc(s) - 1];
                a.GatePercent = Math.trunc(r % 1 * 100);
                setPlanetSubHexData(a, r);
                c.push(a);
                if (t == 0) {
                    var i = {
                        ID: 1,
                        activationType: h,
                        enabled: true,
                        name: "earth"
                    };
                    o += 180;
                    if (o > 360)
                        o -= 360;
                    i.longitude = o;
                    r = getPosInHexagram(o);
                    s = Math.trunc(r);
                    i.Gate = hexMap[Math.trunc(s) - 1];
                    i.GatePercent = Math.trunc(r % 1 * 100);
                    setPlanetSubHexData(i, r);
                    c.push(i)
                }
                if (t == 3) {
                    var l = {
                        ID: 4,
                        activationType: h,
                        enabled: true,
                        name: "south_node"
                    };
                    o += 180;
                    if (o > 360)
                        o -= 360;
                    l.longitude = o;
                    r = getPosInHexagram(o);
                    s = Math.trunc(r);
                    l.Gate = hexMap[Math.trunc(s) - 1];
                    l.GatePercent = Math.trunc(r % 1 * 100);
                    setPlanetSubHexData(l, r);
                    c.push(l)
                }
            }
        }
    )
}

function getPosInHexagram(e) {
    var t = 0;
    if (e > 360)
        e -= 360;
    var n;
    if (e < 3.875) {
        t = 64;
        var a = (e + 360 - ((64 - 1) * 5.625 + 3.875)) / 5.625;
        n = t + a
    } else {
        for (var o = 1; o <= 64; o++) {
            var r = 3.875 + 5.625 * o;
            if (r > e) {
                t = o;
                break
            }
        }
        var a = (e - (3.875 + (t - 1) * 5.625)) / 5.625;
        n = t + a
    }
    return n
}
function setPlanetSubHexData(e, t) {
    var n = t % 1 * 5.625;
    var a = n / .9375;
    e.Line = Math.floor(a) + 1;
    e.LinePercent = Math.trunc(a % 1 * 100);
    a -= Math.trunc(a);
    a = a * .9375 / .15625;
    e.Color = Math.floor(a) + 1;
    e.ColorPercent = Math.trunc(a % 1 * 100);
    a -= Math.trunc(a);
    a = a * .15625 / .0260416666666667;
    e.Tone = Math.floor(a) + 1;
    e.TonePercent = Math.trunc(a % 1 * 100);
    a -= Math.trunc(a);
    a = a * .0260416666666667 / .00520833333333333;
    e.Base = Math.floor(a) + 1;
    e.BasePercent = Math.trunc(a % 1 * 100)
}
function getPlanetBody(e) {
    switch (e.toUpperCase()) {
        case "SUN":
            return $moshier.body.sun;
        case "MOON":
            return $moshier.body.moon;
        case "MERCURY":
            return $moshier.body.mercury;
        case "VENUS":
            return $moshier.body.venus;
        case "MARS":
            return $moshier.body.mars;
        case "JUPITER":
            return $moshier.body.jupiter;
        case "SATURN":
            return $moshier.body.saturn;
        case "URANUS":
            return $moshier.body.uranus;
        case "NEPTUNE":
            return $moshier.body.neptune;
        case "PLUTO":
            return $moshier.body.pluto;
        case "TRUE_NODE":
            return {
                key: "true_node"
            };
        case "CHIRON":
            return $moshier.body.chiron;
        default:
            return $moshier.body.sun
    }
}
function calculateText(e) {
    const t = calculateActivedCentersEdges(e.planetsR, e.planetsL);
    var a = t.map(e=>e.centers);
    a.forEach((e,t)=>{
            if (e.length > 2) {
                for (var n = 1; n < e.length; n++)
                    a.push([e[0], e[n]]);
                a.splice(t, 1)
            }
        }
    );
    e.activatedCenters = t.flatMap(e=>e.centers);
    e.connectedComp = Object.values(connectedComp(a)).filter(e=>e.length > 1);
    e.type = calculateType(e.activatedCenters, e.connectedComp);
    e.profile = calculateProfile(e.planetsR, e.planetsL);
    e.definition = calculateDefinition(e.connectedComp);
    e.innerAuthority = calculateInnerAuthority(e.activatedCenters);
    e.incarnationCross = calculateIncarnationCross(e.planetsR, e.planetsL);
    e.strategy = calculateStrategy(e.type);
    e.notSelfTheme = calculateNotSelfTheme(e.type)
}
function calculateDreamText(e) {
    const t = calculateActivedCentersEdges(e.planetsR, e.planetsL);
    var a = t.map(e=>e.centers);
    a.forEach((e,t)=>{
            if (e.length > 2) {
                for (var n = 1; n < e.length; n++)
                    a.push([e[0], e[n]]);
                a.splice(t, 1)
            }
        }
    );
    e.activatedCenters = t.flatMap(e=>e.centers);
    e.connectedComp = Object.values(connectedComp(a)).filter(e=>e.length > 1);
    e.type = calculateType(e.activatedCenters, e.connectedComp)
}
function calculateType(e, t) {
	if (e.length === 0)
		return "反映者";
	const n = e.includes("sacral");
	const a = e.includes("throat");
	const o = t.find(e=>e.includes("throat"));
	const r = ["sacral", "emotional", "root", "will"].some(e=>o?.includes(e));
	return n ? r ? "顯示生產者" : "生產者" : r ? "顯示者" : "投射者"
}
function calculateProfile(e, t) {
    return `${e[0].Line}/${t[0].Line}`
}
function calculateDefinition(e) {
    const t = ["沒有定義", "一分人", "二分人", "三分人", "四分人"];
    return t[e.length]
}
function connectedComp(e) {
    function n(e, t) {
        if (e[t] === t)
            return t;
        return n(e, e[t])
    }
    var t = {
        emotional: "emotional",
        sacral: "sacral",
        spleen: "spleen",
        will: "will",
        gcenter: "gcenter",
        head: "head",
        throat: "throat",
        ajna: "ajna",
        root: "root"
    };
    const a = Object.keys(t);
    e.forEach(e=>{
            t[n(t, e[0])] = n(t, e[1])
        }
    );
    a.forEach(e=>t[e] = n(t, t[e]));
    var o = {
        emotional: [],
        sacral: [],
        spleen: [],
        will: [],
        gcenter: [],
        head: [],
        throat: [],
        ajna: [],
        root: []
    };
    a.forEach(e=>o[t[e]].push(e));
    return o
}
function calculateInnerAuthority(e) {
    const t = ["emotional", "sacral", "spleen", "will", "gcenter", "throat", "ajna"];
    const n = ["情緒型權威", "薦骨型權威", "直覺型權威", "自我型權威", "自我投射權威", "頭腦型權威", "頭腦型權威"];
    for (var a = 0; a < 8; a++) {
        const o = t[a];
        if (e.includes(o))
            return n[a]
    }
    return "沒有内在權威"
}
function calculateIncarnationCross(e, t) {
    const n = e[0].Line > 4 ? "左角度" : e[0].Line === 4 && t[0].Line === 1 ? "並列" : "右角度";
    const a = `(${e[0].Gate}/${e[1].Gate} | ${t[0].Gate}/${t[1].Gate})`;
    const o = (hexMap.indexOf(e[0].Gate) + 9) % 64;
    const r = o % 16;
    const s = Math.floor(o / 16);
    const i = ["人面獅身", "解釋", "感染", "沉睡的鳳凰", "計劃", "意識", "統領", "伊甸園", "愛之船", "服務", "張力", "滲透", "馬雅", "律法", "不預期", "四方之路"];
    const l = [["面具", "革命", "勤奮", "靈魂", "遷移", "支配", "告知", "飛機", "療癒", "動盪", "努力", "號角", "限制", "希望", "校準", "輪迴"], ["挑戰", "奉獻", "不確定", "二元性", "指認", "分離", "衝突", "教育", "預防", "要求", "個人主義", "循環", "朦朧", "分心", "創始者", "精緻"]];
    const c = [["傾聽", "原則", "命運", "情緒", "交易", "懷疑", "優雅", "危機", "天真", "意見", "控制", "驚嚇", "完成", "突變", "照顧", "體悟"], ["駕駛", "同化", "貢獻", "當下", "實驗", "經驗", "所有權", "發聲", "極端", "靜止", "挑釁", "開始", "細節", "刺激", "影響", "隱私"], ["相互影響", "公式化", "承諾", "策略", "拒絕", "困惑", "壓抑", "衝突", "因緣俱足", "修正", "深度", "直覺", "保存", "價值", "風險", "警覺"], ["自我表達", "洞見", "激勵", "力量", "聚焦", "習慣", "魔術師", "想法", "行為", "活力", "對抗", "抱負", "思考", "限制", "幻想", "需要"]];
    var u = n === "右角度" ? i[r] : n === "左角度" ? l[s % 2][r] : c[s][r];
    if (n === "右角度" && s > 0)
        u += s + 1;
    if (n === "左角度" && s > 1)
        u += "2";
    return `${n}交叉之${u} ${a}`
}
function calculateStrategy(e) {
    return e.includes("生產者") ? "等待回應" : e === "顯示者" ? "告知" : e === "投射者" ? "等待邀請" : "等待28天"
}
function calculateNotSelfTheme(e) {
    return e.includes("生產者") ? "挫敗" : e === "顯示者" ? "憤怒" : e === "投射者" ? "苦澀" : "失望"
}
function calculateActivedCentersEdges(e, t) {
    const n = e.concat(t);
    const i = Array.from(n).filter(e=>e.enabled).map(e=>e.Gate);
    const l = {
        head: {
            gates: [64, 61, 63],
            connections: [47, 24, 4]
        },
        ajna: {
            gates: [47, 24, 4, 17, 43, 11],
            connections: [64, 61, 63, 62, 23, 56]
        },
        throat: {
            gates: [62, 23, 56, 16, 35, 12, 31, 8, 33, 45],
            connections: [17, 43, 11, 48, 36, 22, 7, 1, 13, 21],
            special: {
                gate: 20,
                connections: [10, 34, 57]
            }
        },
        gcenter: {
            gates: [1, 7, 13, 15, 2, 46, 25],
            connections: [8, 31, 33, 5, 14, 29, 51],
            special: {
                gate: 10,
                connections: [20, 34, 57]
            }
        },
        sacral: {
            gates: [5, 14, 29, 27, 42, 3, 9, 59],
            connections: [15, 2, 46, 50, 53, 60, 52, 6],
            special: {
                gate: 34,
                connections: [10, 20, 57]
            }
        },
        root: {
            gates: [53, 60, 52, 54, 19, 38, 39, 58, 41],
            connections: [42, 3, 9, 32, 49, 28, 55, 18, 30]
        },
        spleen: {
            gates: [48, 44, 50, 32, 28, 18],
            connections: [16, 26, 27, 54, 38, 58],
            special: {
                gate: 57,
                connections: [10, 20, 34]
            }
        },
        will: {
            gates: [26, 51, 21, 40],
            connections: [44, 25, 45, 37]
        },
        emotional: {
            gates: [6, 37, 22, 36, 49, 55, 30],
            connections: [59, 40, 12, 35, 19, 39, 41]
        }
    };
    const c = [];
    Object.keys(l).forEach(a=>{
            const e = l[a].gates;
            const o = l[a].connections;
            const t = l[a].special;
            e.forEach((t,e)=>{
                    if (i.includes(t) && i.includes(o[e])) {
                        const n = c.find(e=>e.connections.includes(t));
                        if (n !== undefined) {
                            n.centers.push(a);
                            n.connections.push(o[e])
                        } else {
                            c.push({
                                centers: [a],
                                connections: [o[e]]
                            })
                        }
                    }
                }
            );
            if (t != null) {
                const r = t.gate;
                const s = t.connections;
                if (i.includes(r)) {
                    var n = false;
                    s.forEach(e=>{
                            if (n)
                                return;
                            if (i.includes(e)) {
                                const t = c.find(e=>e.connections.includes(r));
                                if (t !== undefined) {
                                    t.centers.push(a);
                                    t.connections.push(e)
                                } else {
                                    c.push({
                                        centers: [a],
                                        connections: s
                                    })
                                }
                                n = true;
                                return
                            }
                        }
                    )
                }
            }
        }
    );
    return c
}
const fixingArray = [10, 2, 7, 6, 1, 7, 8, 1, 10, 7, 12, 1, 7, 6, 7, 9, 10, 8, 7, 6, 1, 5, 9, 5, 5, 1, 10, 7, 12, 6, 7, 11, 1, 7, 12, 0, 1, 2, 7, 2, 12, 6, 9, 0, 12, 8, 7, 5, 1, 7, 12, 6, 2, 11, 0, 10, 12, 6, -1, 11, 5, 12, 7, 6, 12, 11, 12, 0, 2, 6, 6, 5, 5, 6, 5, 11, 5, 2, 10, 0, 11, 6, 10, 5, 5, 11, 1, 0, 9, 2, 5, 8, 0, 8, 12, 6, 7, 12, 8, 12, 0, 1, 7, 2, 1, 8, 12, 2, 2, 0, 7, 5, 2, 1, 5, 10, 7, 8, 9, 12, 7, 2, 7, 11, 6, 12, 0, 2, 5, 2, 8, 11, 8, 6, 5, 9, 7, 11, 5, 1, 7, 0, 1, 0, 2, 6, 0, 2, 6, 1, 6, 12, 8, 11, 5, 7, 5, 8, 7, 8, 11, 1, 7, 2, 6, 0, 1, 0, 7, 6, 1, 0, 5, 1, 9, 8, 12, 8, 6, 12, 5, 1, 5, 0, 7, 2, 7, 8, 2, 12, 8, 11, 6, 7, 2, 0, 1, 12, 8, 12, 7, 10, 8, 2, 8, 1, 2, 12, 8, 11, 5, 1, 10, 9, 2, 7, 2, 0, 5, 8, 2, 6, 6, 7, 8, 1, 7, 8, 2, 6, 2, 6, 1, 0, 5, 8, 10, 9, 5, 6, 2, 7, 11, 7, 8, 11, 1, 8, 12, 8, 6, 12, 7, 2, 8, 0, 7, 9, 7, 11, 7, 8, 7, 0, 7, 8, 2, 8, 12, 0, 1, 0, 2, 8, 8, 7, 11, 0, 7, 2, 8, 6, 11, 9, 7, 2, 12, 8, 5, 11, 7, 5, 12, 7, -1, 6, 8, 6, 10, 1, 7, 11, 12, 0, 9, 0, 9, 12, 6, 7, 2, 0, 1, 0, 7, 2, 7, 12, 7, 8, 9, 8, 12, 2, 6, 7, 8, 0, 8, 9, 5, 8, 0, 12, 11, 12, 11, 7, 6, 0, 8, 7, 6, 9, 1, 0, 8, 7, 8, 0, 7, 0, 8, 12, 8, 12, 12, 8, 2, 7, 1, 0, 5, 8, 8, 0, 7, 2, 2, 12, 2, 0, 7, 0, 8, 6, 8, 5, 9, 8, 7, 2, 11, 12, 7, 0, 11, 8, 7, 8, 11, 12, 8, 12, 8, 0, 12, 9, 6, 7, 5, 9, 7, 12, 2, 7, 8, 1, 11, 6, 2, 6, 0, 8, 7, 2, 8, 5, 7, 9, 8, 7, 2, 11, 8, 12, 2, 12, 5, 12, 9, 8, -1, 6, 5, 8, 7, 8, 9, 2, 7, 6, 5, 6, 7, 11, 2, 12, 1, 0, 7, 12, 12, 9, 1, 9, 5, 7, 8, 2, 1, 8, 0, 2, 7, 11, 7, 2, 2, 0, 2, 0, 7, 12, 7, 10, 1, 10, 1, 0, 5, 11, 7, 9, 2, 9, 6, 1, 6, 7, 12, 9, 6, 0, 6, 0, 2, 7, 6, 2, 6, 0, 9, 2, 6, 12, 2, 12, 2, 12, 8, 5, 6, 2, 7, 0, 6, 12, 7, 8, 11, 7, 0, 12, 7, 10, 1, 12, 7, 8, 7, 10, 7, 11, 7, 8, 8, 10, 8, 10, 8, 11, 7, 0, 7, 2, 12, 1, 11, 2, 11, 9, 11, 9, 5, 9, 7, 8, 2, 9, -1, 6, 0, -1, 7, 2, 6, 12, 5, 2, 1, 0, 2, 7, 2, 6, 0, 8, 12, 1, 12, 11, 7, 8, 7, 2, 9, 11, 6, 7, 6, 0, 5, 2, 7, 9, 7, 9, 2, 6, 6, 12, 5, 7, 8, 0, 5, 10, 7, 0, 12, 0, 7, 1, 7, 6, 6, 9, 8, 9, 12, 1, 11, 6, 6, 11, 7, 2, 7, 2, 6, 2, 1, 11, 12, 2, 6, 12, 7, 9, 6, 12, -1, -1, -1, 0, 8, 9, 6, 8, 1, 6, 7, 9, 7, 8, 0, 10, 2, 9, 7, 2, 2, 10, 6, 0, 5, 2, 7, 10, 12, 0, 2, 6, 2, 6, -1, 5, 7, 6, 2, 12, 7, 10, 2, 6, 10, -1, 7, 10, 11, 12, 0, 2, 5, 2, 5, 0, 12, 10, 7, 9, 5, 6, 10, 0, 5, 6, 5, 6, 1, 9, 7, 9, 6, 5, 8, 11, 5, 10, 6, 11, 7, 2, 7, 2, 8, 9, 7, 9, 7, 12, 7, 11, 5, 9, 6, 10, 12, 6, 11, 2, 5, 9, 7, 0, 10, 8, 9, 8, 7, 5, 7, 0, 12, 8, 7, 6, 2, 6, 2, 9, 7, 2, 8, 6, 6, 5];
function reverseGraph(e, t, n) {
    var a = {
        year: 1850,
        month: 1,
        day: 1,
        hours: 0,
        minutes: 0,
        seconds: 0
    };
    var o = gateLineToLong(e);
    var [r,s] = calArrivalDate("pluto", $moshier.body.pluto, o, 2396758.5, a, true, 5e4);
    a.year = r.getFullYear();
    a.month = r.getMonth() + 1;
    a.day = r.getDate();
    var i = gateLineToLong(t);
    var [l,c] = calArrivalDate("sun", $moshier.body.sun, i, s, a, true, 5e4, false);
    if (Math.abs(calLongFromJul(c, $moshier.body.pluto) - o) > 1) {
        console.log("Using Approx for Sun");
        [l,c] = calArrivalDate("sun", $moshier.body.sun, i, s, a, true, 5e4, true);
        if (Math.abs(calLongFromJul(c, $moshier.body.pluto) - o) > 1) {
            console.log("Adding one year for Sun");
            l = new Date(l.getTime() + 1e3 * 86400 * 300);
            a.year = l.getFullYear();
            a.month = l.getMonth() + 1;
            a.day = l.getDate();
            [l,c] = calArrivalDate("sun", $moshier.body.sun, i, s + 300, a, true, 5e4, true);
            if (Math.abs(calLongFromJul(c, $moshier.body.pluto) - o) > 1)
                console.log("Cannot find arrival for Sun")
        }
    }
    a.year = l.getFullYear();
    a.month = l.getMonth() + 1;
    a.day = l.getDate();
    var u = gateLineToLong(n);
    var [h,d] = calArrivalDate("moon", $moshier.body.moon, u, c, a, true, 5e4, false);
    if (Math.abs(calLongFromJul(d, $moshier.body.sun) - i) > 1) {
        console.log("Using Approx for Moon");
        [h,d] = calArrivalDate("moon", $moshier.body.moon, u, c, a, true, 5e4, true);
        if (Math.abs(calLongFromJul(d, $moshier.body.sun) - i) > 1)
            console.log("Cannot find arrival for Moon")
    }
    console.log(`${r}\n${l}\n${h}`);
    console.log(`UTC: ${h.toString().slice(4).split(" G")[0]}`)
}
function gateLineToLong(e) {
    const t = parseInt(e);
    const n = parseInt((e - t) * 10 + .1);
    const a = hexMap.indexOf(t);
    var o = 3.875 + a * 5.625 + (n - 1) * .9375;
    if (o > 360)
        o -= 360;
    return o
}

module.exports = {
	calculatePlanetData,
	calLongFromDate,
	calculateDesignDate,
	calculateText,
	calculateDreamText,
	calculateMoonDesignDate,
}